package com.wdy.po;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import com.wdy.util.BasicUtil;
@SuppressWarnings({"unchecked", "serial"})
public class Repair implements Comparable, Serializable {
	
	private Integer rid;
	private String title;
	private Date rdate;
	private String content;
	private String dealState;
	private Date dealDate;
	private String transactor;
	private String note;
	private Set<Tenement> tenements;
	
	public Repair() {
		super();
	}

	public Repair(Integer rid, Date rdate, String content, String dealState,
			Date dealDate, String transactor, String note,
			Set<Tenement> tenements) {
		super();
		this.rid = rid;
		this.rdate = rdate;
		this.content = content;
		this.dealState = dealState;
		this.dealDate = dealDate;
		this.transactor = transactor;
		this.note = note;
		this.tenements = tenements;
	}

	public Integer getRid() {
		return rid;
	}

	public void setRid(Integer rid) {
		this.rid = rid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getRdate() {
		return rdate;
	}

	public void setRdate(Date rdate) {
		this.rdate = rdate;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getDealState() {
		return dealState;
	}

	public void setDealState(String dealState) {
		this.dealState = dealState;
	}

	public Date getDealDate() {
		return dealDate;
	}

	public void setDealDate(Date dealDate) {
		this.dealDate = dealDate;
	}

	public String getTransactor() {
		return transactor;
	}

	public void setTransactor(String transactor) {
		this.transactor = transactor;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Set<Tenement> getTenements() {
		return tenements;
	}

	public void setTenements(Set<Tenement> tenements) {
		this.tenements = tenements;
	}
/*
	@Override
	public boolean equals(Object o) {
		if(null == o) {
			return false;
		}
		if(o instanceof Repair){
			Repair contrastRepair = (Repair)o;
			Integer contrastRid = contrastRepair.getRid();
			Date contrastDate = contrastRepair.getDate();
			if(this.rid.equals(contrastRid) && this.date.equals(contrastDate)){
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.rid.hashCode() * this.date.hashCode();
	}
*/
	@Override
	public String toString() {
		String str = this.rdate.toString() + tenements.toString();
		return str;
	}

	public int compareTo(Object o) {
		Repair contrastRepair = (Repair)o;
		Integer contrastRid = contrastRepair.getRid();
		int orignalId = this.rid.intValue();
		int contrastId = contrastRid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((rdate == null) ? 0 : rdate.hashCode());
		result = prime * result + ((rid == null) ? 0 : rid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Repair))
			return false;
		final Repair other = (Repair) obj;
		if (rdate == null) {
			if (other.rdate != null)
				return false;
		} else if (!rdate.equals(other.rdate))
			return false;
		if (rid == null) {
			if (other.rid != null)
				return false;
		} else if (!rid.equals(other.rid))
			return false;
		return true;
	}
}
